<style lang="less" scoped>
.div1{width:400px;padding:20px 0px;margin:0px auto;}
</style>

<template>
<div>
    <div class="div1">
        <Input v-model="user.userName" title="username" placeholder="username" />
        <br/>
        <Input v-model="user.pwd" placeholder="pwd" type="password">
            
        </Input>
        <i-button @click="login" type="primary">登录</i-button>
    </div>
    
</div>
</template>
<script>
export default {
    data(){
        return {
            user:{userName:'star',pwd:''}
        }
    },
    methods:{
        login(){
            var t=this.$route.query.redirect || "/";
            this.axios.post('/mock/user/login',this.user).then(res=>{
                console.log(res);
                if(res.errorCode==0){
                    this.$store.dispatch('user_update',{
                        data:res.data
                    }).then(()=>{
                        this.$router.push(t);
                    })
                }
                
            })
            
        }
    }
}
</script>
